﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace card
{
    public partial class PrinForm2 : Form
    {
        string Str_ID = "";
        string Str_BT = "";
        public static WebDG.Service ws = new card.WebDG.Service();
        public PrinForm2(string _ID, string _BT)
        {
            Str_ID = _ID;
            Str_BT = _BT;
            InitializeComponent();
        }
        DateTime dtnow = DateTime.Now;
        string str_ph = "";
        string str_djsj = "";
        public void sss()
        {

            string sql = "  SELECT  XPBH AS BH " +
               " ,TRUCKNO AS CH,LOGINTIME AS DJSJ,COMMANDTIME AS ZLSJ,CARDTIME AS QRSJ,SHIPNAME||'/'||VOYAGE  AS CMHC "
               + ",BILL_NO  AS TDH,PIECES AS JS,CARGONAME AS HM,WEIGHT AS ZL,YARD AS DD,ZYJX AS JX, REMARK AS BZ "
               + " ,ZDR AS DZY,CARDADD AS TCC,DYRQ AS ZDSJ,'" + Str_BT + "' AS BT "//
             + "   FROM TRUCK_CARGO_LOGIN_XPDY WHERE XPBH='" + Str_ID + "'";
            DataSet ds = ws.getDataSet_Serv(sql);

            str_ph = ds.Tables[0].Rows[0][0].ToString();
            //str_djsj = ds.Tables[0].Rows[0]["DJSJ"].ToString();

            reportViewer1.ProcessingMode = ProcessingMode.Local;
            // WF_PROJECT.Properties.Resources.JTReport

            //SoundPlayer ddd = new SoundPlayer(WF_PROJECT.Properties.Resources.JTReport);

            reportViewer1.LocalReport.ReportEmbeddedResource = "card.Reportp.rdlc";//"JTReport.rdlc";//@"..\..\REPT\JTReport.rdlc";
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));
            //  reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReportData_年月", DALFactory.GetShipDataProvider().GetDataTableYearMounth(YearMonth)));
            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport();
        }

        private void reportViewer1_PrintingBegin(object sender, ReportPrintEventArgs e)
        {
            StringBuilder sbsql1 = new StringBuilder();
            sbsql1.Append(" UPDATE TRUCK_CARGO_LOGIN_XPDY ");
            sbsql1.Append(" SET DYCS=DYCS+1");
            sbsql1.AppendFormat("  WHERE XPBH = '{0}' ", Str_ID);

            ws.execute_UID_Serv(sbsql1.ToString());
            //DYBZ
            this.reportViewer1.ShowPrintButton = false;
        }

        private void PrinForm2_Load(object sender, EventArgs e)
        {
            sss();
        }

    }
}
